"""
    获取攻击比例大于6的所有技能
    要求：使用生成器函数、生成器表达式
"""


class SkillData:
    """技能数据"""
    def __init__(self, ids, name, atk_ratio, duration):
        self.ids = ids
        self.name = name
        self.atk_ratio = atk_ratio
        self.duration = duration

    def __str__(self):
        return f"{self.ids}, {self.name}, {self.atk_ratio}, {self.duration}"


list1 = [
    SkillData(101, "乾坤大挪移", 5, 10),
    SkillData(101, "乾坤大挪移", 8, 5),
    SkillData(101, "乾坤大挪移", 10, 2)
]


class SkillConntrol:
    def __iter__(self):
        """生成器函数"""
        for i in range(len(list1)):
            if list1[i].atk_ratio > 6:
                yield list1[i]

    def expression(self):
        """生成器表达式"""
        return (list1[r] for r in range(len(list1)) if list1[r].atk_ratio > 6)


if __name__ == "__main__":
    do = SkillConntrol()
    for i in do:    # 生成器函数
        print(i)
    print("---------------------")

    # 生成器表达式
    for c in do.expression():
        print(c)